import React from 'react';
import {inject, observer} from 'mobx-react';
import * as mobx from 'mobx';
import {WeaLocaleProvider, WeaTools} from "ecCom";

const getLabel = WeaLocaleProvider.getLabel;
const Base64 = WeaTools.Base64;

export default class Main extends React.Component {
    constructor(props) {
        super(props);
    }

    renderItemList2(list) {
        return list.map((item, index) => {
            let {fieldLabel, showName1, showName2, isBase64} = item;

            if (isBase64) {
                if (!!showName1) {
                    showName1 = Base64.decode(showName1);
                }

                if (!!showName2) {
                    showName2 = Base64.decode(showName2);
                }
            }

            return (
                <li><span>[{fieldLabel}]：</span>
                    <span>"</span>
                    <span dangerouslySetInnerHTML={{__html: showName2}}></span>
                    <span>"</span>
                    <span>&nbsp;{getLabel(501211, "被改为")}&nbsp;</span>
                    <span>"</span>
                    <span className="red" dangerouslySetInnerHTML={{__html: showName1}}></span>
                    <span>"</span>
                </li>
            );
        });
    }

    renderItemList1(list) {
        return list.map((item, index) => {
            let {fieldLabel, showName, isBase64} = item;

            if (isBase64) {
                if (!!showName) {
                    showName = Base64.decode(showName);
                }
            }

            return (
                <li>
                    <span>[{fieldLabel}]：</span>
                    <span>&nbsp;</span>
                    <span dangerouslySetInnerHTML={{__html: showName}}></span>
                </li>
            );
        });
    }


    render() {
        const {datas, checkResult} = this.props;
        return (
            <div className="mainFieldLogs">
                <ol>{checkResult === "2" ? this.renderItemList2(datas) : this.renderItemList1(datas)}</ol>
            </div>
        );
    }
}